function validateUserName(){
	var name=document.getElementById("userName").value;
//	alert(name);
	var pattern=/^[a-zA-Z][a-zA-Z0-9_]{4,15}$/;
	if(!pattern.test(name)){
		document.getElementById("user_msg").innerHTML="用户名格式错误";	
		return;
	}
	validate(name);
}
function validate(name){
	var xmlHttp;
	try{
		xmlHttp=new XMLHttpRequest();
	}catch(e){
		try{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}catch(e){
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		}	
	}
	
	var url="validateUserNameAction?name="+name;
//	alert("hello");
	xmlHttp.open("GET",url,true);
	xmlHttp.onreadystatechange=function(){
//		alert("回调啦我日啊");
		if(xmlHttp.readyState==4){
			if(xmlHttp.status==200){
				var result=xmlHttp.responseText;
				if(result=="0"){
					document.getElementById("user_msg").innerHTML="用户名正确";
				}else{
					document.getElementById("user_msg").innerHTML="用户名已存在";
				}
			}
		}
	};
	xmlHttp.send(null);
	
}